<?php 
	$result = safe_query("SELECT * FROM news ORDER BY DATE DESC LIMIT 10");
	$num_rows = mysql_num_rows($result);
	$lst_news = array();
	while($news = mysql_fetch_array($result ))
	{
		$lst_news[] = $news;
	}
?>
<script type="text/javascript" src="js/lastest_news.js"></script>
<script type="text/javascript" src="js/ajax_news_comment.js"></script>
<div id="news" class="clearafter">
	<div class="left">
		<div class="left_inner">
			<?php 
			if ($num_rows > 0) {
				$lastes_news = $lst_news[0];
				$result_count = safe_query("SELECT COUNT(*) AS count FROM comments WHERE newsID = " . $lastes_news["newsID"]);
				$data_count = mysql_fetch_assoc($result_count);
				$count_comment = $data_count["count"];
			?>
			<h1 class="heading-page"><?=$lastes_news["title"] ?></h1>
			<div class="newsInfo clearafter">
				<span class="left"><?=date("F j, Y", $lastes_news["date"])?></span>
				<div class="addthis">
					<a href="#" class="facebook"></a>
					<a href="#" class="print"></a>
					<a href="#" class="email"></a>
					<a href="#" class="twitter"></a>
					<a href="#" class="plus"></a>
				</div>
				<span class="right"><?=$count_comment?> Commments</span>
			</div>
			<div class="newsContent">
				<img src="<?=$lastes_news["pic"] ?>" alt="img" title="img" />
				<p class="newsDes">
					<?=$lastes_news["description"] ?>
				</p>
				<div class="content">
					<p>
						<?=$lastes_news["content"]?> 
					</p>
				</div>
			</div>
			<div id="newsComment">
				<div class="top clearafter">
					<span class="openComment">Open Comments</span>
					<div class="right">
						<!-- AddThis Button BEGIN -->
						<div class="addthis_toolbox addthis_default_style ">
						<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
						<a class="addthis_button_tweet"></a>						
						<a class="addthis_counter addthis_pill_style"></a>
						</div>
						<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
						<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-501ea0700d4bdd3d"></script>
						<!-- AddThis Button END -->
					</div>
				</div>
				<div class="newsCommentForm clearafter">
					<form method="post" action="">
						<h3>Add new comment</h3>
						<div class="commentArea">
							<textarea>Type your comment here</textarea>
						</div>
						<button class="hide">Submit</button>
					</form>
				</div>
				<div class="commentListing">
					<h3>5 comments</h3>
					<ul>
						<li class="parent">
							<div class="commentWrap">
								<h4>SomeUsrname</h4>
								<div class="commentContent">
									Aliquam posuere, nibh sit amet tincidunt posuere, libero nulla venenatis tellus, non malesuada diam metus vel ligula. Nullam rutrum felis a lacus convallis placerat. Vivamus ullamcorper purus at justo pharetra venenatis. Nunc quis tortor nulla, et pretium ipsum. Nullam ut placerat arcu. Etiam sagittis congue est vitae vulputate. 
								</div>
								<div class="commentExInfo clearafter">
									<span>6 days ago</span>
									<div class="right">
										<a href="#">Like</a>
										<a href="#">Reply</a>
									</div>
								</div>
							</div>							
						</li>
						<li class="parent">
							<div class="commentWrap">
								<h4>SomeUsrname</h4>
								<div class="commentContent">
									Proin urna turpis, eleifend eu vehicula id, dignissim sit amet mi. Donec justo lacus, consequat sit amet mollis vel, tempus eu nisl. Ut vitae nibh eu lectus fringilla vestibulum eu eu lacus. Phasellus iaculis erat sed arcu venenatis cursus. 
								</div>
								<div class="commentExInfo clearafter">
									<span>6 days ago</span>
									<div class="right">
										<a href="#">Like</a>
										<a href="#">Reply</a>
									</div>
								</div>
							</div>
							<ul>
								<li class="child">
									<div class="commentWrap">
										<h4>SomeUsrname</h4>
										<div class="commentContent">
											Aliquam posuere, nibh sit amet tincidunt posuere, libero nulla venenatis tellus, non malesuada diam metus vel ligula. Nullam rutrum felis a lacus convallis placerat. Vivamus ullamcorper purus at justo pharetra venenatis. Nunc quis tortor nulla, et pretium ipsum. Nullam ut placerat arcu. Etiam sagittis congue est vitae vulputate. 
										</div>
										<div class="commentExInfo clearafter">
											<span>6 days ago</span>
											<span>in reply to CoolUsrname</span>
											<span>1 Like</span>
											<span class="flag"><img src="images/flag.png" /></span>
											<div class="right">
												<a href="#">Like</a>
												<a href="#">Reply</a>
											</div>
										</div>
									</div>
									<ul>
										<li class="child">
											<div class="commentWrap">
												<h4>SomeUsrname</h4>
												<div class="commentContent clearafter">
													Aliquam posuere, nibh sit amet tincidunt posuere, libero nulla venenatis tellus, non malesuada diam metus vel ligula. Nullam rutrum felis a lacus convallis placerat. 
												</div>
												<div class="commentExInfo">
													<span>6 days ago</span>
													<div class="right">
														<a href="#">Like</a>
														<a href="#">Reply</a>
													</div>
												</div>
											</div>							
										</li>								
									</ul>
								</li>								
							</ul>	
						</li>
						<li class="parent">
							<div class="commentWrap">
								<h4>SomeUsrname</h4>
								<div class="commentContent">
									Aliquam posuere, nibh sit amet tincidunt posuere, libero nulla venenatis tellus, non malesuada diam metus vel ligula. 
								</div>
								<div class="commentExInfo clearafter">
									<span>6 days ago</span>
									<div class="right">
										<a href="#">Like</a>
										<a href="#">Reply</a>
									</div>
								</div>
							</div>							
						</li>						
					</ul>					
				</div>
			</div>
			<?php } ?>
		</div>
	</div>
	<div class="right">
		<div class="right_inner">
			<h3>Latest News</h3>
			<ul class="newsListing">
				<?php
        		for ($i = 0; $i < $num_rows; $i++ )
				{ 
					$news = $lst_news[$i];
				?>
				<li <?=$i == 0 ? "class=\"first\"" : ($i == $num_rows - 1 ? "class=\"last\"" : "")?>>
					<a href="#" id="<?=$news["newsID"]?>"><?=$news["title"]?></a>
				</li>
				<?php
				}
				?>
			</ul>
		</div>
	</div>
</div>